package com.chao.product.conf.rabbitmq;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 路由模式
 * 一对一完全匹配
 * 一个routingKey对应一个Queue
 */
@Configuration
public class DirectConfig {

    @Bean
    public Queue directQueue1(){
        return new Queue("direct_queue_1");
    }

    @Bean
    public Queue directQueue2(){
        return new Queue("direct_queue_2");
    }

    @Bean
    public DirectExchange setDirectExchange(){
        return ExchangeBuilder.directExchange("direct_exchange").build();
    }

    @Bean
    public Binding setDirectQueue1(){
        return BindingBuilder.bind(directQueue1()).to(setDirectExchange()).with("direct.queue.1");
    }

    @Bean
    public Binding setDirectQueue2(){
        return BindingBuilder.bind(directQueue2()).to(setDirectExchange()).with("direct.queue.2");
    }

}
